import os

import execjs

node = execjs.get()

crypto_js_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static', 'js', 'crypto-js.min.js')
ctx = node.compile(open(crypto_js_file, encoding='utf-8').read())


def eval(js):
    """
    eval("CryptoJs.AES.encrypt('encrypt', CryptoJs.enc.Utf8.parse('sdfsdf'), {mode: CryptoJs.mode.ECB}).toString()")
    """
    return ctx.eval(js)


if __name__ == '__main__':
    print(eval(
        "CryptoJs.AES.encrypt('encrypt', CryptoJs.enc.Utf8.parse('sdfsdf'), {mode: CryptoJs.mode.ECB}).toString()"))
